/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author navneet
 */
public class ECAFB extends org.apache.struts.validator.ValidatorActionForm {
    private int id;
    private int groupId;
    private String companyName;
    private String description;
    private String error;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public ECAFB() {
        super();
    }

    @Override
    public void reset(ActionMapping mapping,HttpServletRequest request){
        id              =   -1;
        groupId         =   -1;
        companyName     =   "";
        description     =   "";
        error           =   "";
    }
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getGroupId() < 1) {
            errors.add("groupId", new ActionMessage("error.ACAFB.groupId.required"));
        }
        if (getCompanyName() == null || getCompanyName().length() < 1) {
            errors.add("companyName", new ActionMessage("error.ACAFB.companyName.required"));
        }
        return errors;
    }
}
